<?php namespace App\Models\Cxhshop;

use App\Models\Base\CxhshopBase;
use Illuminate\Support\Facades\DB;
class Store extends CxhshopBase { 
    protected $table = 'ims_cxh_store';
    //获取全部类型(车辆)
    public function getstore($condition=array(),$page=1,$number =10){ 
           // $filed = ['id','title','img','created_at','updated_at','name'];
        $query = self::query();

        if(!empty($condition['name'])){
            $name  = '%'.$condition['name'].'%';
            $count = $query->where('name','like',$name)->forPage($page,$number)->get()->count();
           
            if($count>0){
                $date =$query->where('name','like',$name)->forPage($page,$number)->orderBy('created_at','desc')->get()->toArray();
                return $date;
            }else{
                return false;
            }
            
        }else{
            $count = $query->forPage($page,$number)->orderBy('created_at','desc')->get()->count();
            if($count>0){
                $date =$query->forPage($page,$number)->orderBy('created_at','desc')->get()->toArray();
                return $date;
            }else{
                return false;
            }
            
        }
        
    }
}